package ca.concordia.soen6011.tests;
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import ca.concordia.soen6011.Result;
import ca.concordia.soen6011.exceptions.InfinityOutputException;
import ca.concordia.soen6011.exceptions.UndefinedOutputException;
import ca.concordia.soen6011.impl.LnX;
import ca.concordia.soen6011.interfaces.MathFunction;


public class TestLnX {
private  MathFunction f;
	
	@Before
	public void setUp(){
		f = new LnX();
	}
	
	@Test
	public void testForBasicInputs(){
		
		Result r = new Result();
		try 
		{
		r = f.compute(Math.PI, 2);
		assertEquals(1, r.getOutput(), r.getPrecision());
		
	r = f.compute(Math.E,1);		
		assertEquals(1.434, r.getOutput(), r.getPrecision());
		
		} catch (InfinityOutputException | UndefinedOutputException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
				//Exception.
	}
	
	@Test(expected=Exception.class)
	public void testForExceptions(){
		
		Result r = new Result();
		try{
		r = f.compute(0, 2);
		
		} catch (InfinityOutputException | UndefinedOutputException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
//		assertEquals(1, r.getOutput(), r.getDecimalPrecision());
		
//		r = f.compute(Math.E,1);		
//		assertEquals(1.434, r.getOutput(), r.getDecimalPrecision());
//		
//		Exception.
	}


}
